//
//  LSCellExponentCell.m
//  LookScore
//
//  Created by wr on 2018/5/11.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSCellExponentCell.h"
#import "LSAIHistoricaModel.h"
@interface LSCellExponentCell()

@property (nonatomic,strong)UILabel *companyName;
@property (nonatomic, strong) NSMutableArray *instantLableArray;
@property (nonatomic, strong) NSMutableArray *firstCountArray;
@end


@implementation LSCellExponentCell
- (UILabel *)companyName{
    if (!_companyName) {
        _companyName = [[UILabel alloc] init];
        _companyName.font = LSFontSize12;
        _companyName.textAlignment = NSTextAlignmentCenter;
        _companyName.textColor = LSSubColor5D5D5D;
    }
    return _companyName;
}
- (NSMutableArray *)instantLableArray{
    if (!_instantLableArray) {
        _instantLableArray = [NSMutableArray array];
        
    }
    return _instantLableArray;
}
- (NSMutableArray *)firstCountArray{
    if (!_firstCountArray) {
        _firstCountArray = [NSMutableArray array];
        
    }
    return _firstCountArray;
    
}
+ (LSCellExponentCell *)CellExponentTableviewCellByTableView:(UITableView *)tableView{
    LSCellExponentCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSCellExponentCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
    CGFloat width = (LSScreenWidth-30)/5;
    
//    self.companyName.text = @"卡普空";
    [self.contentView addSubview:self.companyName];
    self.companyName.sd_layout
    .leftEqualToView(self.contentView)
    .widthIs(width)
    .topEqualToView(self.contentView)
    .bottomEqualToView(self.contentView);
    
    
//    NSArray *titleArray = @[@"1.23",@"平/半",@"0.18"];
    UILabel *instantLable; //即时
    UILabel *firstCount;   //初盘
    for (int i = 0; i < 3; i ++) {
        
        instantLable=[UILabel new];
//        instantLable.text = titleArray[i];
        instantLable.textColor = LSSubColor5D5D5D;
        instantLable.font=LSFontSize12;
        instantLable.textAlignment = NSTextAlignmentCenter;
        [self.instantLableArray addObject:instantLable];
        [self.contentView addSubview:instantLable];
        instantLable.sd_layout.leftEqualToView(self.companyName).offset(width*(i+2)).centerYEqualToView(self.contentView).offset(-10).widthIs(width).heightIs(37/2);
        
        
        firstCount=[UILabel new];
//        firstCount.text = titleArray[i];
        firstCount.textColor = LSSubColor5D5D5D;
        firstCount.font=LSFontSize12;
        firstCount.textAlignment = NSTextAlignmentCenter;
        [self.firstCountArray addObject:firstCount];
        [self.contentView addSubview:firstCount];
        firstCount.sd_layout.leftEqualToView(self.companyName).offset(width*(i+2)).topSpaceToView(instantLable, 0).widthIs(width).heightIs(37/2);
    }
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = LSSubGrayColorf7;
    [self.contentView addSubview:line];
    line.sd_layout.leftEqualToView(self.contentView).bottomEqualToView(self.contentView).offset(-1).rightEqualToView(self.contentView).heightIs(1);
}



- (void)setModel1:(LSOddsChangeRecordModel *)model1{

    _model1 = model1;
    companyDataList * listModel1 = model1.companyDataList.firstObject;
    companyDataList * listModel2 = model1.companyDataList.lastObject;
    self.companyName.text = model1.CompanyName;
    if (model1.companyDataList.count == 1) {
        
        NSArray *array1 = @[[NSString stringWithFormat:@"%.2f",listModel2.Odds_Win],[NSString stringWithFormat:@"%.2f",listModel2.Odds_Flat],[NSString stringWithFormat:@"%.2f",listModel2.Odds_Negative]];
        [self.firstCountArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UILabel *lable = (UILabel *)obj;
            lable.text = array1[idx];
        }];
        [self.instantLableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UILabel *lable = (UILabel *)obj;
            lable.text = array1[idx];
        }];
    }else{
        NSArray *array1 = @[[NSString stringWithFormat:@"%.2f",listModel2.Odds_Win],[NSString stringWithFormat:@"%.2f",listModel2.Odds_Flat],[NSString stringWithFormat:@"%.2f",listModel2.Odds_Negative]];
        [self.firstCountArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UILabel *lable = (UILabel *)obj;
            lable.text = array1[idx];
        }];
        //即时
        NSArray *array = @[[NSString stringWithFormat:@"%.2f",listModel1.Odds_Win],[NSString stringWithFormat:@"%.2f",listModel1.Odds_Flat],[NSString stringWithFormat:@"%.2f",listModel1.Odds_Negative]];
        NSArray * colorArray = @[@(listModel1.winColorState),@(listModel1.flatColorState),@(listModel1.negativeColorState)];
        [self.instantLableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UILabel *lable = (UILabel *)obj;
            lable.text = array[idx];
            NSInteger state = [colorArray[idx] intValue];
            switch (state) {
                case 1:
                    lable.textColor = RGB(237,93,88);
                    break;
                case -1:{
                    lable.textColor = RGB(90,226,55);
                }
                    break;
                case 0:{
                    lable.textColor = RGB(93,93,93);
                }
                    break;
                default:
                    break;
            }
        }];

        
    }
    
    

}

- (void)setModel2:(LSAIHistoricaModel *)model2{
    _model2 = model2;
//    "HD_KD" = "0.75";
//    "HD_PK" = "\U5e73\U624b";
//    "HD_ZD" = "1.05";
    companyDataList * listModel1 = model2.companyDataList.firstObject;
    companyDataList * listModel2 = model2.companyDataList.lastObject;
    self.companyName.text = model2.CompanyName;
    
    NSArray *array = @[listModel1.HD_ZD,listModel1.HD_PK,listModel1.HD_ZD];
    [self.instantLableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array[idx];
    }];
    
    NSArray *array1 = @[listModel2.HD_ZD,listModel2.HD_PK,listModel2.HD_ZD];
    [self.firstCountArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array1[idx];
    }];
    
}
- (void)setModel3:(LSSDHistoricaModel *)model3{
    _model3 = model3;
    
    companyDataList * listModel1 = model3.companyDataList.firstObject;
    companyDataList * listModel2 = model3.companyDataList.lastObject;
    self.companyName.text = model3.CompanyName;
    NSArray *array = @[listModel1.HD_DQ,listModel1.HD_PK,listModel1.HD_XQ];
    [self.instantLableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array[idx];
    }];
    
    NSArray *array1 = @[listModel2.HD_DQ,listModel2.HD_PK,listModel2.HD_XQ];
    [self.firstCountArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array1[idx];
    }];
}
@end
